<?php
namespace RMD\AccountBundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

use RMD\AccountBundle\Entity\Condition;
use RMD\AccountBundle\Form\DataTransformer\TestTransformer;

class TestType extends AbstractType
{
	public function __construct() {

	}

	public function buildForm(FormBuilderInterface $builder, array $options) {
		//var_dump($options['data']);
		$condition = $options['data'];
		$segmentOptions = $options['segmentOptions'];
		$condition->setColumnName($segmentOptions['columnName']);
		$condition->setTableName($segmentOptions['tableName']);
		$choices = array();
		foreach ($segmentOptions['statements'] as $constName => $string) {
			$choices[constant('RMD\AccountBundle\Entity\Condition::' . $constName)] = $string;
		}
		$builder->add('statement', 'choice', array(
			'choices'   => $choices,
			'required'  => true,
		));
		$builder->add('matchValue', 'text');
	}

    public function getName() {
        return 'test';
    }
    /*public function getDefaultOptions(array $options)
    {

    }*/
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'RMD\AccountBundle\Entity\Condition',
            'intention'       => 'test_item'
        ));
		$resolver->setRequired(array('segmentOptions'));
    }
}
?>
